package state

import (
	"fmt"
	"reflect"
)

type tMockFileStream struct {
	state iFileStreamState
	file  string
}


func NewMockFileStream(file string) IFileStream {
	fs := &tMockFileStream{
		nil,
		file,
	}
	fs.state = newDefaultState(fs)
	return fs
}

func (me *tMockFileStream) File() string {
	return me.file
}

func (me *tMockFileStream) Switch(st iFileStreamState) {
	fmt.Printf("tMockFileStream.Switch, %s => %s\n", reflect.TypeOf(me.state).String(), reflect.TypeOf(st).String())
	me.state = st
}

func (me *tMockFileStream) OpenRead() error {
	return me.state.OpenRead()
}

func (me *tMockFileStream) OpenWrite() error {
	return me.state.OpenWrite()
}

func (me *tMockFileStream) Read(p []byte) (n int, e error) {
	return me.state.Read(p)
}

func (me *tMockFileStream) Write(p []byte) (n int, e error) {
	return me.state.Write(p)
}

func (me *tMockFileStream) Close() error {
	return me.state.Close()
}